﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgNetComponents.Classes
{
    /// <summary>
    /// Class to specify how different values should be converted to bool
    /// </summary>
    public class BoolStateObject
    {
        static BoolStateObject()
        {
            standardTrueValues = new BoolStateObject[]{
                new BoolStateObject("1"),
                new BoolStateObject("1.0"),
                new BoolStateObject("Y"),
                new BoolStateObject("YES"),
                new BoolStateObject("TRUE")
            };

            standardFalseValues = new BoolStateObject[]{
                new BoolStateObject("0"),
                new BoolStateObject("0.0"),
                new BoolStateObject("N"),
                new BoolStateObject("NO"),
                new BoolStateObject("FALSE")
            };
        }

        private static BoolStateObject[] standardTrueValues;
        private static BoolStateObject[] standardFalseValues;

        /// <summary>
        /// Gets or sets values that will be converted to True using object.AsBool() extension method
        /// </summary>
        public static BoolStateObject[] StandardTrueValues
        {
            get { return standardTrueValues; }
            set { standardTrueValues = value; }
        }
        /// <summary>
        ///  Gets or sets values that will be converted to False using object.AsBool() extension method
        /// </summary>
        public static BoolStateObject[] StandardFalseValues
        {
            get { return standardFalseValues; }
            set { standardFalseValues = value; }
        }

        /// <summary>
        /// Gets or sets value
        /// </summary>
        public object Value { get; set; }

        /// <summary>
        /// Gets or sets if Value should be converted to string during comparing
        /// </summary>
        public bool ConvertToString { get; set; }

        /// <summary>
        /// Gets or sets if compare strings is case insensitive
        /// </summary>
        public bool IgnoreCase { get; set; }

        /// <summary>
        /// Creates BoolStateObject instance
        /// </summary>
        /// <param name="value">Value</param>
        /// <param name="convertToString"></param>
        /// <param name="ignoreCase"></param>
        public BoolStateObject(object value, bool convertToString = true, bool ignoreCase = true)
        {
            Value = value;
            ConvertToString = convertToString;
            IgnoreCase = ignoreCase;
        }
    }
}
